package cn.wendellup.bootStrap.valueobject.entity;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

public class AdvPositionLink implements Serializable, RowMapper<AdvPositionLink> {

    private static final long serialVersionUID = 8342109696813530691L;

    private int advPositionId;
    private int appId;
    private int sortNo;
    private String type = "";

    public static class FieldStatus {
        public static int type = 1 << 0;
        public static int sortNo = 1 << 1;
    }

    private int updateStatus = 0;

    public int getAdvPositionId() {
        return advPositionId;
    }

    public void setAdvPositionId(int advPositionId) {
        this.advPositionId = advPositionId;
    }

    public int getAppId() {
        return appId;
    }

    public void setAppId(int appId) {
        this.appId = appId;
    }

    public int getSortNo() {
        return sortNo;
    }

    public void setSortNo(int sortNo) {
        if (this.sortNo != sortNo) {
            this.sortNo = sortNo;
            this.updateStatus = this.updateStatus | AdvPositionLink.FieldStatus.sortNo;
        }
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        if (this.type != type) {
            this.type = type;
            this.updateStatus = this.updateStatus | AdvPositionLink.FieldStatus.type;
        }
    }

    public int getUpdateStatus() {
        return updateStatus;
    }

    public void setUpdateStatus(int updateStatus) {
        this.updateStatus = updateStatus;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("AdvPositionLink [advPositionId=");
        builder.append(advPositionId);
        builder.append(", appId=");
        builder.append(appId);
        builder.append(", sortNo=");
        builder.append(sortNo);
        builder.append(", type=");
        builder.append(type);
        builder.append(", updateStatus=");
        builder.append(updateStatus);
        builder.append("]");
        return builder.toString();
    }

	@Override
	public AdvPositionLink mapRow(ResultSet rs, int arg1) throws SQLException {
		AdvPositionLink advPositionLink = new AdvPositionLink();
		advPositionLink.setAdvPositionId(rs.getInt("adv_position_id"));
		advPositionLink.setAppId(rs.getInt("app_id"));
		advPositionLink.setSortNo(rs.getInt("sort_no"));
		advPositionLink.setType(rs.getString("type"));
		return advPositionLink;
	}

}
